package com.ruoyi.zsyh.controller;

import java.util.List;

import com.ruoyi.zsyh.domain.ZsyhAgentPartsattribute;
import com.ruoyi.zsyh.service.IZsyhAgentPartsattributeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAgentParts;
import com.ruoyi.zsyh.service.IZsyhAgentPartsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大区商城配件管理Controller
 * 
 * @author yuexl
 * @date 2021-12-16
 */
@Controller
@RequestMapping("/zsyh/agentParts")
public class ZsyhAgentPartsController extends BaseController
{
    private String prefix = "zsyh/agentParts";

    @Autowired
    private IZsyhAgentPartsService zsyhAgentPartsService;
    @Autowired
    private IZsyhAgentPartsattributeService zsyhAgentPartsattributeService;

    @RequiresPermissions("zsyh:agentParts:view")
    @GetMapping()
    public String agentParts()
    {
        return prefix + "/agentParts";
    }

    /**
     * 查询大区商城配件管理列表
     */
    @RequiresPermissions("zsyh:agentParts:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAgentParts zsyhAgentParts)
    {
        startPage();
        List<ZsyhAgentParts> list = zsyhAgentPartsService.selectZsyhAgentPartsList(zsyhAgentParts);
        return getDataTable(list);
    }

    /**
     * 导出大区商城配件管理列表
     */
    @RequiresPermissions("zsyh:agentParts:export")
    @Log(title = "大区商城配件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAgentParts zsyhAgentParts)
    {
        List<ZsyhAgentParts> list = zsyhAgentPartsService.selectZsyhAgentPartsList(zsyhAgentParts);
        ExcelUtil<ZsyhAgentParts> util = new ExcelUtil<ZsyhAgentParts>(ZsyhAgentParts.class);
        return util.exportExcel(list, "大区商城配件管理数据");
    }

    /**
     * 新增大区商城配件管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存大区商城配件管理
     */
    @RequiresPermissions("zsyh:agentParts:add")
    @Log(title = "大区商城配件管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAgentParts zsyhAgentParts)
    {
        return toAjax(zsyhAgentPartsService.insertZsyhAgentParts(zsyhAgentParts));
    }

    /**
     * 修改大区商城配件管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAgentParts zsyhAgentParts = zsyhAgentPartsService.selectZsyhAgentPartsById(id);
        mmap.put("zsyhAgentParts", zsyhAgentParts);
        return prefix + "/edit";
    }

    /**
     * 修改大区商城配件管理
     */
    @GetMapping("/viewParts/{id}")
    public String viewParts(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAgentParts zsyhAgentParts = zsyhAgentPartsService.selectZsyhAgentPartsById(id);
        mmap.put("zsyhAgentParts", zsyhAgentParts);
        return prefix + "/viewParts";
    }

    /**
     * 修改大区商城配件管理
     */
    @GetMapping("/viewParts/viewAgentAttribute")
    public String viewAgentAttribute(String id, ModelMap mmap)
    {
        ZsyhAgentPartsattribute zsyhAgentPartsattribute = zsyhAgentPartsattributeService.selectZsyhAgentPartsattributeById(id);
        mmap.put("zsyhAgentPartsattribute", zsyhAgentPartsattribute);
        return prefix + "/viewAgentAttribute";
    }

    /**
     * 修改保存大区商城配件管理
     */
    @RequiresPermissions("zsyh:agentParts:edit")
    @Log(title = "大区商城配件管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAgentParts zsyhAgentParts)
    {
        return toAjax(zsyhAgentPartsService.updateZsyhAgentParts(zsyhAgentParts));
    }

    /**
     * 删除大区商城配件管理
     */
    @RequiresPermissions("zsyh:agentParts:remove")
    @Log(title = "大区商城配件管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAgentPartsService.deleteZsyhAgentPartsByIds(ids));
    }
}
